package com.warmguard.core.config;


import io.minio.MinioClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.ConfigurationPropertiesScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * ClassName: MinioConfig
 * PackageName: com.enquan.lease.common.minio
 * Description:
 *
 * @Author: 32782
 * @Date: 9/8/2024 下午10:17
 * @Version: 1.0
 */


//@EnableConfigurationProperties(MinioConfig.class)
//会扫描这个包下的配置类
@ConfigurationPropertiesScan("com.warmguard.core.config")
@Configuration
@ConditionalOnProperty(name = "minio.endpoint")
public class MinioConfig {
    @Autowired
    private MinioProperties minioProperties;
    @Bean
    public MinioClient minioClient(){
        MinioClient minioClient = MinioClient.builder()
                .endpoint(minioProperties.getEndpoint())
                .credentials(minioProperties.getAccessKey(), minioProperties.getSecretKey()).build();

    return minioClient;
    }
}
